home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------------------------
- *
- * File: ResolveAliasAA.c - C Source
- *
- * Author: Deric Horn
- *
- * Action Atom to resolve alias files of specified infs file
- *
- * History: <1> (12/2/94) Created this file.
- *
- *----------------------------------------------------------------------------*/
-
- #include <Resources.h>
- #include <Aliases.h>
- #include "AtomUtils.h"
-
-
- // Function Prototypes
- pascal long RESOLVEALIAS(AAPBRecPtr myAAPBPtr);
- OSErr myResolveAlias (AAPBRecPtr myAAPBPtr);
-
-
- pascal long RESOLVEALIAS(AAPBRecPtr myAAPBPtr)
- {
- OSErr err = noErr;
-
- if (myAAPBPtr->whichStage == after) // make sure that this is the right stage
- { // and that the atom is not being called
- // as a result of a cancel operation
- err = myResolveAlias( myAAPBPtr );
- return ( err );
- }
- return( 1 );
- }
-
- OSErr myResolveAlias (AAPBRecPtr myAAPBPtr)
- {
- infsHdl myinfsH;
- infsPtr myinfs;
- Handle theAlias;
- FSSpec from,to;
- short myResFile;
- short aResFileRefNum;
- unsigned char changed;
- OSErr err = noErr;
-
- myinfsH=(infsHdl)Get1Resource('infs',myAAPBPtr->aaRefCon);
- if (myinfsH!=0)
- {
- HLock((Handle)myinfsH); // lock and dereference
- myinfs=*myinfsH;
-
- if ( MakeFSSpecFromAAPB( &from, myinfs->pathName, myAAPBPtr ) == noErr )
- {
- myResFile=CurResFile(); // store current resfile
- aResFileRefNum=FSpOpenResFile(&from, fsWrPerm); // open the rsrcfork
-
- theAlias=Get1Resource('alis',0);
- if (theAlias!=0)
- {
- if (ResolveAlias(&from,(AliasHandle)theAlias,&to,&changed)==noErr)
- {
- if (changed)
- {
- ChangedResource(theAlias);
- UpdateResFile(aResFileRefNum);
- err = noErr;
- }
- }
- else err = 1;
- }
- CloseResFile(aResFileRefNum); // close the damn thing
- UseResFile(myResFile); // restore current resfile
-
- if (err==1)
- FSpDelete(&from); // if we could not resolve the alias delete it.
- }
- HUnlock((Handle)myinfsH);
- }
- return(noErr);
- }
-